<#include "/WEB-INF/template/common/macro/base.ftl"/>
<#include "/WEB-INF/template/common/macro/libs.ftl"/>
<#include "/WEB-INF/template/common/layout/l_admin.ftl"/>
<@adminLayout>
    <@breadcrumb view=breadcrumbView/>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="tabbable-custom ">
                    <ul class="nav nav-tabs ">
                        <li class="active"><a href="#baseinfo" data-toggle="tab">基本信息</a></li>
                        <li class=""><a href="#favorite" data-toggle="tab">用户收藏</a></li>
                        <li class=""><a href="#address" data-toggle="tab">用户地址</a></li>
                        <li class=""><a href="#weixin" data-toggle="tab">微信信息</a></li>
                        <li class=""><a href="#account" data-toggle="tab">电子账户</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="baseinfo">
                            <div class="portlet box light-grey">
                                <div class="portlet-title">
                                    <div class="caption"><i class="fa fa-globe"></i>用户信息</div>
                                    <div class="actions">
                                    </div>
                                </div>
                                <div class="portlet-body form">
                                    <form class="form-horizontal form-body" action="${CONTEXT_PATH}/user/saveinfo">
                                        <h3 class="form-section">用户信息</h3>
                                        <input type="hidden" name="m.uuid" value="${m.getUserInfo().uuid}"/>
                                        <table class="table table-bordered table-striped">
                                            <tr>
                                                <td width="10%">用户编号</td>
                                                <td width="25%"><input type="text" class="form-control" name="m.memberid" placeholder="用户编号" value="${m.getUserInfo().memberid!}" readonly></td>
                                                <td width="15%"><span class="status"></span></td>
                                                <td width="10%">用户密码</td>
                                                <td width="25%">*****</td>
                                                <td width="15%"><span class="status"></span></td>
                                            </tr>
                                            <tr>
                                                <td>认证信息</td>
                                                <td colspan="5">
                                                    <table class="table table-bordered">
                                                        <tr>
                                                            <td colspan="2">
                                                                <div class="alert alert-success">
                                                                    当前认证状态:
                                                                    <#if m.isPass()>
                                                                        <span class="label label-success">认证通过</span>
                                                                    <#else>
                                                                        <span class="label label-danger">未认证</span>
                                                                    </#if>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>真实姓名</td>
                                                            <td><input type="text" class="form-control input-medium" name="m.realname" placeholder="用户编号" value="${m.getUserInfo().realname!}" readonly></td>
                                                        </tr>
                                                        <tr>
                                                            <td>身份证</td>
                                                            <td><input type="text" class="form-control input-medium" name="m.idcard" placeholder="身份证" value="${m.getUserInfo().idcard!}" readonly></td>
                                                        </tr>
                                                        <tr>
                                                            <td>手机号码</td>
                                                            <td><input type="text" class="form-control input-medium" name="m.phone" placeholder="手机号码" value="${m.getUserInfo().phone!}" readonly></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>用户等级</td>
                                                <td>
                                                    <input type="text" class="form-control" name="m.rankend" placeholder="用户等级" value="${m.getUserRank().getRankname()}">
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                                <td>用户等级</td>
                                                <td>
                                                    <input type="text" class="form-control" name="m.rankend" placeholder="用户等级" value="${m.getUserRank().getRankname()}">
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>是否默认</td>
                                                <td>
                                                    <select class="form-control" name="m.isdefault">
                                                        <option value="true">是</option>
                                                        <option value="false">否</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                                <td>用户等级</td>
                                                <td>
                                                    <input type="text" class="form-control" name="m.rankend" placeholder="用户等级" value="${m.getUserRank().getRankname()}">
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>是否有效</td>
                                                <td>
                                                    <select class="form-control" name="m.liveflag">
                                                        <option value="1">有效</option>
                                                        <option value="0">无效</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                                <td>是否有效</td>
                                                <td>
                                                    <select class="form-control" name="m.liveflag">
                                                        <option value="1">有效</option>
                                                        <option value="0">无效</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>备注</td>
                                                <td colspan="4">
                                                    <textarea rows="3" name="m.remark" class="form-control">${m.remark!}</textarea>
                                                </td>
                                                <td>
                                                    <span class="status"></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td></td>
                                                <td colspan="5">
                                                    <input type="submit" class="btn btn-primary"/>
                                                    <input type="reset" class="btn btn-default"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="favorite">
                            <div class="portlet box light-grey">
                                <div class="portlet-title">
                                    <div class="caption"><i class="fa fa-globe"></i>用户收藏</div>
                                    <div class="actions">
                                    </div>
                                </div>
                                <div class="portlet-body form">
                                    <div id="favorite_dt_grid" class="dt-grid-container portlet-body" >

                                    </div>
                                    <div id ="favorite_dt_table_toolbar" class="dt-grid-toolbar-container">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="address">
                            <div class="portlet box light-grey">
                                <div class="portlet-title">
                                    <div class="caption"><i class="fa fa-globe"></i>收获地址</div>
                                    <div class="actions">
                                    </div>
                                </div>
                                <div class="portlet-body form">
                                    <div id="address_dt_grid" class="dt-grid-container portlet-body" >

                                    </div>
                                    <div id ="address_dt_table_toolbar" class="dt-grid-toolbar-container">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="weixin">
                            <p>Howdy, I'm in Section 3.</p>
                            <p>
                                Duis autem vel eum iriure dolor in hendrerit in vulputate.
                                Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat
                            </p>
                            <p>
                                <a class="btn yellow" href="ui_tabs_accordions_navs.html#tab_5_3" target="_blank">Activate this tab via URL</a>
                            </p>
                        </div>
                        <div class="tab-pane" id="account">
                            <p>Howdy, I'm in Section 3.</p>
                            <p>
                                Duis autem vel eum iriure dolor in hendrerit in vulputate.
                                Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat
                            </p>
                            <p>
                                <a class="btn yellow" href="ui_tabs_accordions_navs.html#tab_5_3" target="_blank">Activate this tab via URL</a>
                            </p>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
    <!--model begin-->
    <@Modal_CURD "ajax_add" "modal-wide" "users_add"/>
    <@Modal_CURD "ajax_update" "modal-wide" "users_update"/>
    <@Modal_SystemOpera/>
    <!--model end-->
</div>

<form action="${CONTEXT_PATH}/user/update" method="post" id="users_update" class="form-horizontal">
    <input type="hidden" name="m.uuid" value="${m.uuid}"/>
</form>
<@script>
    <@libs_dtgrid_js/>
    <@libs_dtgrid_css/>
    <@libs_jquery_validate_js/>
<script type="text/javascript">
    var address_dtgrid="";
    var favorite_dtgrid="";
    jQuery(document).ready(function () {
        initAddressList();
        initFavoriteList();
    });

    function initAddressList(){
        var address_columnModel = [
            {id:'memberid', title:'用户', type:'string', columnClass:'text-center'},
            {id:'province', title:'省份', type:'string',columnClass:'text-center'},
            {id:'city', title:'城市', type:'string', codeTable:DTGRID_STATIC_LIB.LIVEFLAG,columnClass:'text-center'},
            {id:'area', title:'区域', type:'string', columnClass:'text-center'},
            {id:'street', title:'街道', type:'string', columnClass:'text-center'},
            {id:'address', title:'地址', type:'string', columnClass:'text-center'},
            {title:'操作',columnClass:'text-center',
                resolution:function(value, record){
                    var content = [];
                    content.push("<a href=\"javascript:;\" onclick=\"update(this,'"+record.uuid+"')\" class=\"btn btn-primary btn-xs\">");
                    content.push("<i class=\"fa fa-pencil update\"></i></a>");
                    content.push("<a href=\"javascript:;\" onclick=\"deletebyid(this,'"+record.uuid+"')\" class=\"btn btn-danger btn-xs\">");
                    content.push("<i class=\"fa fa-minus-circle\"></i></a>");
                    return content.join(" ");
                }
            }
        ];

        var address_dtgridOpt = {
            lang: 'zh-cn',
            check: true,
            ajaxLoad: true,
            loadURL: '${CONTEXT_PATH}/user/address/loaduser/${m.getUserInfo().uuid}',
            exportFileName: '收货地址',
            columns: address_columnModel,
            gridContainer: 'address_dt_grid',
            toolbarContainer: 'address_dt_table_toolbar',
            tools: 'print',
            pageSize: 10,
            pageSizeLimit: [10, 20, 50]
        };
        address_dtgrid = $.fn.DtGrid.init(address_dtgridOpt);
        $(function () {
            address_dtgrid.load();
        });
    }

    function initFavoriteList(){
        var favorite_columnModel = [
            {id:'memberid', title:'用户', type:'string', columnClass:'text-center'},
            {id:'name', title:'商品名称', type:'string',columnClass:'text-center'},
        ];

        var favorite_dtgridOpt = {
            lang: 'zh-cn',
            check: true,
            ajaxLoad: true,
            loadURL: '${CONTEXT_PATH}/user/favorite/load/${m.getUserInfo().uuid}',
            exportFileName: '商品收藏',
            columns: favorite_columnModel,
            gridContainer: 'favorite_dt_grid',
            toolbarContainer: 'favorite_dt_table_toolbar',
            tools: 'print',
            pageSize: 10,
            pageSizeLimit: [10, 20, 50]
        };
        favorite_dtgrid = $.fn.DtGrid.init(favorite_dtgridOpt);
        $(function () {
            favorite_dtgrid.load();
        });
    }

    jQuery("#users_update").ready(function () {
        $(this).find("#liveflag").val("${m.liveflag!}");
        phoneChina();  //添加手机号码验证phoneChina
        // 定义验证参数
        var validateOptions = $.extend(CONST_VALIDATE.OPTION, {
            rules: {
                "m.loginid": {
                    required: true,
                    maxlength: 45
                },
                "m.name": {
                    required: true,
                    maxlength: 15
                },
                "m.phone": {
                    required: true,
                    phoneChina: true
                }
            },
            messages: {
                "m.loginid": {
                    required: "<i class='fa fa-exclamation tooltips'></i>请输入登录ID",
                    maxlength: $.validator.format("<i class='fa fa-exclamation tooltips'></i>登录ID不能大于{0}个字符")
                },
                "m.name": {
                    required: "<i class='fa fa-exclamation tooltips'></i>请输入用户昵称",
                    maxlength: $.validator.format("<i class='fa fa-exclamation tooltips'></i>用户昵称不能大于{0}个字符")
                },
                "m.phone": {
                    required: "<i class='fa fa-exclamation tooltips'></i>请输入手机号码",
                    phoneChina: "<i class='fa fa-exclamation tooltips'></i>请输入正确的手机号码",
                }
            },
            submitHandler:function(form) {
                var modal = $("#ajax_update");
                $(form).ajaxSubmit(function (data, status, xhr) {
                    if (data.status) {
                        toastr.success(data.msg, '操作提示');
                    } else {
                        toastr.error(data.msg, '操作提示');
                    }
                });
                $(modal).modal('hide');
                dtgrid.load();
            }
        });
        //表单验证
        var validator = $("#users_update").validate(validateOptions);
    });

</script>
</@script>
</@adminLayout>